//package ltTest.config;
//
//import java.net.UnknownHostException;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//
//import com.fasterxml.jackson.annotation.JsonAutoDetect;
//import com.fasterxml.jackson.annotation.PropertyAccessor;
//import com.fasterxml.jackson.databind.ObjectMapper;
//
//import redis.clients.jedis.HostAndPort;
//import redis.clients.jedis.JedisCluster;
//import redis.clients.jedis.JedisPoolConfig;
//import redis.clients.jedis.JedisShardInfo;
//
//@Configuration
//public class RedisConfig {
//	
//    @Autowired
//    private RedisProperties redisProperties;
//
////	@Bean
////    public JedisCluster JedisClusterFactory() {
////        Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
////        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
////        List<String> list = redisProperties.getCluster().getNodes();
////        for (String s : list) {
////        	jedisClusterNodes.add(new HostAndPort(s.split(":")[0],new Integer(s.split(":")[1])));
////		}
////        JedisCluster jedisCluster = new JedisCluster(jedisClusterNodes, jedisPoolConfig);
////        return jedisCluster;
////    }
//    
////	@Bean
////    @SuppressWarnings({ "rawtypes", "unchecked" })
////    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) throws UnknownHostException {
////        RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
////        template.setConnectionFactory(redisConnectionFactory);
////        Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class);
////        ObjectMapper om = new ObjectMapper();
////        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
////        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
////        jackson2JsonRedisSerializer.setObjectMapper(om);
////        template.setValueSerializer(jackson2JsonRedisSerializer); //1
////        template.setKeySerializer(new StringRedisSerializer()); //2
////        template.afterPropertiesSet();
////        return template;
////    }
//    
//    @Bean
//    public JedisConnectionFactory jedisConnectionFactory(){
//    	return new JedisConnectionFactory(new JedisShardInfo("192.168.142.128", 6379));
//    }
//    
//    @Bean
//    public RedisTemplate<Object, Object> redisTemplate(){
//    	RedisTemplate<Object, Object> template = new RedisTemplate<Object, Object>();
//    	template.setConnectionFactory(jedisConnectionFactory());
//    	template.setKeySerializer(new StringRedisSerializer());
//    	JdkSerializationRedisSerializer jackson2JsonRedisSerializer = new JdkSerializationRedisSerializer();
//        ObjectMapper om = new ObjectMapper();
//        om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
//        om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
//        jackson2JsonRedisSerializer.serialize(om);
//    	template.setValueSerializer(jackson2JsonRedisSerializer);
//    	return template;
//    }
//	
//}
